package com.logica.mdm.webservices.utils;

import javax.transaction.UserTransaction;

import com.siperian.sif.client.SiperianClient;

/**
 * Abstract Runnable implementation that allows subclasses to
 * easily access a SiperianClient and UserTransaction object.
 * @author Fabien Crespel <fabien.crespel@logica.com>
 */
public abstract class SiperianRunnable implements Runnable {

	protected SiperianClient siperianClient;
	protected UserTransaction transaction;

	public SiperianClient getSiperianClient() {
		return siperianClient;
	}

	public void setSiperianClient(SiperianClient siperianClient) {
		this.siperianClient = siperianClient;
	}

	public UserTransaction getTransaction() {
		return transaction;
	}

	public void setTransaction(UserTransaction transaction) {
		this.transaction = transaction;
	}
	
	@Override
	public void run() {
		try {
			doRun();
		} catch (Throwable e) {
			throw new RuntimeException(e);
		}
	}
	
	public abstract void doRun() throws Exception;
}
